package com.tony.springbootmybatis.mapper;

import com.tony.springbootmybatis.entity.Student;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

/**
 * create by xuxia on 2024/2/2 14:44
 */
@Component
@Mapper
public interface StudentMapper {

    @Insert("insert into student(s_no,sname,ssex) values (#{sno},#{sname},#{ssex})")
    int add(Student student);

    @Update("update student set sname=#{sname},ssex=#{ssex} where s_no=#{sno}")
    int update(Student student);

    @Delete("delete from student where s_no=#{sno}")
    int deleteById(String sno);

    @Select("select * from student where s_no=#{sno}")
    @Results(id = "student", value = {
            @Result(property = "sno", column = "s_no", javaType = String.class),
            @Result(property = "sname", column = "sname", javaType = String.class),
            @Result(property = "ssex", column = "ssex", javaType = String.class)
    })
    Student queryStudentById(String sno);
}
